﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SdmxMl.GenericData;
using SdmxMl.Manager;
using SdmxMl.Structure;
using SdmxMl.Panels;

namespace SdmxMl.UC
{
    public partial class UcDataGroup : UserControl
    {
        protected TreeNode treeNode;
        private DataGroupType dataGroup;
        private PanelAnnotationList pannelAnnot;

        public UcDataGroup()
        {
            InitializeComponent();
        }

        public virtual void BindFromNode(TreeNode node, PanelAnnotationList panelAnnotation)
        {
            treeNode = node;
            pannelAnnot = panelAnnotation;
            
            dataGroup = null;
            if (node != null)
            {
                dataGroup = node.Tag as DataGroupType;

            }
            BindToControls();

        }

        private void BindToControls()
        {
            if (dataGroup != null)
            {
                textBoxGroupType.Text = dataGroup.Type;
                Visible = true;
                this.SuspendLayout();

                GroupSerieAttrib gsa = new GroupSerieAttrib();
                gsa.FillGroupEditControls(this.panelGroup, dataGroup.DatasetOwner, dataGroup);

                ucSeries.SetSeries(dataGroup.DatasetOwner, dataGroup.SeriesList);
                this.ResumeLayout(false);

            }
            else
                Visible = false;
        }

        public bool UpdateNodeTag(TreeNode node)
        {
            bool err = false;
            if (node != null)
            {
                err = BindFromControls();
            }

            return err; // true on error
        }

        protected bool BindFromControls()
        {
            bool err = false;
            if (dataGroup != null)
            {
              //  metaSet.Name.UpdateForCurrentLanguage(comboBoxTitle.Text);

            }
            return err;
        }

    }
}
